package com.imooc.mall.config;

import com.imooc.mall.filter.AdminFilter;
import jakarta.servlet.FilterRegistration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AdminFilterConfig {
    @Bean
    public AdminFilter adminFilter() {
        return new AdminFilter();
    }
    @Bean(name = "AdminFilterConf")
    public FilterRegistrationBean adminFilterConfig() {
        FilterRegistrationBean<AdminFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(adminFilter());
        registrationBean.addUrlPatterns("/admin/*");
        registrationBean.setName("adminFilter");
        return registrationBean;
    }
}
